<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="functions.asp" -->
<% 

'set cn=Server.CreateObject("ADODB.Connection")
'cn.Open "MP2ENTPONSL", "MP2", "MP2"
dim sql

   dim tmpSQL
   if (request.querystring("InvStatus") <> "0") then
   tmpSQL=" AND INVSTATUS='"& request.querystring("InvStatus") & "'"
   'else
   'tmpSQL=" AND (INVSTATUS = 'PARKED' OR INVSTATUS = 'ROUTED' OR INVSTATUS = 'PREAPPROVED' OR INVSTATUS = 'APPROVED')"
   end if
   
   if (request.querystring("CurSymbol") <> "N") then
   tmpSQL= tmpSQL & " AND CURRENCYSYMBOL='"& request.querystring("CurSymbol") & "'"
   end if
   
   
   if (request.querystring("Location") <> "") then
   tmpSQL= tmpSQL & " AND LOCATION='"& request.querystring("location") & "'"
   end if
   
   if (request.querystring("UserCoord") <> "") then
   tmpSQL= tmpSQL & " AND USERCOORD='"& request.querystring("UserCoord") & "'"
   end if
   
   if (request.querystring("VendorID") <> "") then
   tmpSQL= tmpSQL & " AND VENDORID='"& request.querystring("VendorID") & "'"
   end if
   
   if (request.querystring("RefOrder") <> "0") then
   tmpSQL= tmpSQL & " AND REFORDER='"& request.querystring("RefOrder") & "'"
   end if
   
   dim tmpSort
   tmpSort="INVRECDATE"
   if (request.querystring("dSort") <> "") then
   tmpSort= request.querystring("dSort")
   end if
   
   dim tmpOrder
   tmpOrder = "ASC"
   if (request.QueryString("dOrder") <>"") then
   tmpOrder= request.QueryString("dOrder")
   end if
   Dim CurrOrder
   if (tmpOrder = "ASC" )then 
   CurrOrder ="DESC"
   else
   CurrOrder="ASC"
   end if
%>
<%
sql= "SELECT *  FROM dbo.COMPCODE"
set CompCode=cn.execute(sql)

sql = "SELECT SEQNUM, REGNUM, INVNUM, INVSTATUS, VENDORID, VENDORBRANCHID, PONUM,INVRECDATE, INVDUEDATE, EMPCODE, LOCATION, DEPARTMENT, "_
& "INVCURRENCY, (SELECT EXCHANGERATE FROM EXCHRATE WHERE EXCHRATE.MP2CURRENCY=EXIREG.INVCURRENCY) AS FRATE,REFERENCEDOC,"_
& "VERIFIEDBY, VERIFIEDSTATUS, AUTHORISEDBY, APPROVEDBY,APPROVED2BY,JOINAPPROVAL,"_
& "DATEVERIFIED,DATEAUTHORISED,DATEAPPROVED,DATEAPPROVED2,MULTIVERIFY,"_
& "CURRENCYSYMBOL, INVAMOUNT, REFORDER, DOC1, DOC2, COMPCODE, VATNUM, WHTNAME, VATRATE, (SELECT LOCNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.LOCATION) AS LOCNAME,"_
& "WHTRATE, WHTAMOUNT, VATPAIDTOVENDOR,   (SELECT TOP 1 VENDOR.NAME  FROM VENDOR  WHERE VENDOR.VENDORID=EXIREG.VENDORID) AS VENDORNAME,    "_
& "(SELECT VERNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.VERIFIEDBY) AS VERNAME,"_
& "(SELECT EMPNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.EMPCODE) AS EMPNAME,"_
& "(SELECT AUTHNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.AUTHORISEDBY) AS AUTHNAME,"_
& "(SELECT APPRNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.APPROVEDBY) AS APPRNAME,"_
& "(SELECT APPRNAME2=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.APPROVED2BY) AS APPRNAME2,"_
& "(SELECT LOCNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.LOCATION) AS LOCNAME,"_
& "COMMENTS  FROM dbo.EXIREG  WHERE  SEQNUM=" & request.querystring("Seqnum")

set EXIREG=cn.execute(sql)

sql = "SELECT *,  (SELECT TRDESCR FROM EXITRTYPE WHERE EXIHIST.TRANSTYPE=EXITRTYPE.TRTYPE) AS TRDESCR ,   "
sql = sql & "ISNULL((SELECT LOCNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME "
sql = sql & "WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END "
sql = sql & "FROM dbo.EMP WHERE EMP.EMPCODE=EXIHIST.LOCATION),EXIHIST.LOCATION) AS LOCNAME " 
sql = sql & "FROM dbo.EXIHIST  WHERE SEQNUM=" & Request.QueryString("seqnum")
sql = sql & "ORDER BY UPDATESTAMP "
set InvHist=cn.execute(sql)

sql = "SELECT *  FROM dbo.EXICHARGE  WHERE INVSEQNUM=" & Request.QueryString("seqnum")
set Acct=cn.execute(sql)

sql = "SELECT *  FROM dbo.EXIVERIFY  WHERE INVSEQNUM=" & Request.QueryString("seqnum")
set Verification=cn.execute(sql)

Dim PONUM
PONUM=EXIREG("PONUM")

sql = "SELECT * FROM EXILINKRCP WHERE SEQNUM=" & Request.QueryString("seqnum")
set RcpLink = cn.execute(sql)

if RcpLink.eof then
  sql = "SELECT RECEIVERNUM, INVOICENUM, INVOICEDATE,INVOICESTATUS, PONUM, QTYRECEIVED, DATERECEIVED, "
  sql = sql & "UNITCOST, LINECOST, UDF  FROM dbo.PORECEIV  "
  sql = sql & "WHERE PONUM = '" & PONUM  & "'  AND INVOICENUM IS NULL"
else
  sql = "SELECT RECEIVERNUM, INVOICENUM, INVOICEDATE,INVOICESTATUS, PONUM, QTYRECEIVED, DATERECEIVED, "
  sql = sql & "UNITCOST, LINECOST, UDF  FROM dbo.PORECEIV  "
  sql = sql & "WHERE PONUM = '" & PONUM  & "'  AND INVOICENUM='" & EXIREG("INVNUM") & "'"
end if

set Receipt = cn.execute(sql)
if Receipt.eof then
isRcp="N"
else
isRcp="Y"
end if

dim isUser
dim isAuthorised
dim isOutLimit
dim TrType
dim Caption1
dim Caption2
dim Verseqnum
verseqnum=0

Function get_Authorise(e)
'if (EXIREG.Fields.Item("APPROVEDBY").Value <> "") then
 sql = "SELECT  A.GROUPDESC, A.EMPCODE, B.CURRENCY, B.INVAMTPO, B.INVAMTNONPO"
 sql = sql & " FROM dbo.EXIAUTHORITY A, dbo.EXIAUTHFINANCE B"
 sql = sql & " WHERE A.GROUPDESC=B.GROUPDESC "
 sql = sql & " AND A.EMPCODE = '" & e & "'"
 set rs = cn.execute(sql)
 
do while not rs.eof
 if (EXIREG("REFORDER") = "Y")or(EXIREG("REFORDER") = "O") then
   if ((EXIREG("INVAMOUNT")/EXIREG("FRATE")) > rs("INVAMTPO")) then
     get_Authorise = "N"
   else
     get_Authorise = "Y"
   end if
 else
   if ((EXIREG("INVAMOUNT")/EXIREG("FRATE")) > rs("INVAMTNONPO")) then
     get_Authorise = "N"
   else
     get_Authorise = "Y"
   end if
 end if
 
rs.movenext
loop
set rs = nothing
'end if

end function

if (EXIREG("APPROVEDBY")<>"")then
isAuthorised=get_Authorise(EXIREG("APPROVEDBY"))
end if

if (EXIREG("APPROVED2BY")<>"")then
isAuthorised=get_Authorise(EXIREG("APPROVED2BY"))
end if


if(EXIREG("JOINAPPROVAL")="Y") then
  caption1="Approved 1 By:"
  caption2="Approved 2 By:"
else
  caption1="Approved By:"
end if

%>
<SCRIPT Language="JavaScript">
String.prototype.reverse = function () {return this.split('').reverse().join('')}; 
Number.prototype.withCommas = function () { 
if (isNaN (this)) return NaN.toString(); 
var l = Math.floor(Math.abs(this)).toString(); 
var r = Math.round((Math.abs(this) % 1) * 100).toString(); 
return [(this < 0 ? '-' : ''), (l.length > 3 ? l.reverse().match(/\d{1,3}/g).join(',').reverse() : l),'.', (r < 10 ? '0' + r : r)].join(''); 
} 

function Valid_Charge(dField, x, y){
var re=/\,/g;//untuk mereplace koma
var ldField=dField.length;
var dtTotal=y;
var initval=Number(x.value.replace(re,""));
var t=document.getElementsByTagName("input");
var total=0;
var total_s="";
if (initval!=0)
for (var j=0; j<t.length; j++){
if (t[j].name.substring(0,ldField)==dField){
total_s=t[j].value.replace(re,"");
total+=Number(t[j].value.replace(re,""));
}
}
 if (total > dtTotal ){
     alert(total_s+ " " + String(dtTotal) + " " +"Total amount is greater than invoice amount!");
     x.focus();
	 x.value=0;
     return false;
	 }
	 else {

x.value=initval.withCommas();
return true
}
//x.value=Number(x.value.replace(re,"")).withCommas();

}

//function show_hist(dfield){
//var txt=document.getElementById("caption3");
//if (dfield.checked) {
//document.getElementById("inv_hist").style.display='block';
//txt.innerHTML='Hide History';
//} 
//else {
//document.getElementById("inv_hist").style.display='none';
//txt.innerHTML='View History';}
/*
function DocLoad(){
var joinAppr='<%=(EXIREG("JOINAPPROVAL"))%>';
var isAuthorised='<%= isAuthorised %>';
document.getElementById("inv_hist").style.display='none';
document.form1.reqInvoiceNo.focus();
if (joinAppr=='N'){
  document.getElementById("Approved2").style.display='none';
  }
if (isAuthorised=='N'){
  document.getElementById("Authorise").style.display='block';
  }
else
  {
  document.getElementById("Authorise").style.display='none';
  }
}
*/
function DocLoad(){
}
var InvStatus='<%= request.querystring("InvStatus") %>';
var dsort='<%= request.querystring("dsort") %>';
var dorder='<%= request.querystring("dorder") %>';
var Location='<%= request.querystring("Location") %>';
var UserCoord='<%= request.querystring("UserCoord") %>';
var RefOrder='<%= request.querystring("refOrder") %>';
var VendorID='<%= request.querystring("VendorID") %>';
var CurSymbol='<%= request.querystring("CurSymbol") %>';
var RecDate='<%= request.querystring("RecDate") %>';
var RecDate2='<%= request.querystring("RecDate2") %>';
var RptCond='<%= request.querystring("RptCond") %>';

//function DocLoad(){
//document.form1.reqInvoiceNo.focus();
//}

function doblock(){
if (document.form1.Comments.value==""){
alert("Please enter your reason in Comments Box!");
return false;
}
else{
return blocked('<%=(EXIREG("SEQNUM"))%>')
}
}

function redirect(){
location='InvListComment.asp?InvStatus='+InvStatus+'&dsort='+ dsort+'&dorder='+ dorder+'&Location='+Location+'&UserCoord='+UserCoord+'&RefOrder='+RefOrder+'&VendorID='+VendorID+'&CurSymbol='+CurSymbol+'&RecDate='+RecDate+'&RecDate2='+RecDate2+'&RptCond='+RptCond;
return false
}

function reroute(a,b){
var Status='<%=(EXIREG("INVSTATUS"))%>';
if (Status=='APPROVED'){
 if (confirm('Invoice already APPROVED. Are You sure you want to reroute this invoice?')==true){
 location='Inv_Routing.asp?route='+a+ '&seqnum='+b+'&InvStatus='+InvStatus+'&dsort='+ dsort+'&dorder='+ dorder+'&Location='+Location+'&UserCoord='+UserCoord+'&RefOrder='+RefOrder+'&VendorID='+VendorID+'&CurSymbol='+CurSymbol+'&RecDate='+RecDate+'&RecDate2='+RecDate2+'&RptCond='+RptCond;
 return true;
 }
 else
 return false;
}
else
location='Inv_Routing.asp?route='+a+ '&seqnum='+b+'&InvStatus='+InvStatus+'&dsort='+ dsort+'&dorder='+ dorder+'&Location='+Location+'&UserCoord='+UserCoord+'&RefOrder='+RefOrder+'&VendorID='+VendorID+'&CurSymbol='+CurSymbol+'&RecDate='+RecDate+'&RecDate2='+RecDate2+'&RptCond='+RptCond;
return true
}

function register(){
location='Inv_Register.asp?InvStatus='+InvStatus+'&dsort='+ dsort+'&dorder='+ dorder+'&Location='+Location+'&UserCoord='+UserCoord+'&RefOrder='+RefOrder+'&VendorID='+VendorID+'&CurSymbol='+CurSymbol+'&RecDate='+RecDate+'&RecDate2='+RecDate2+'&RptCond='+RptCond;
return false
}

function blocked(dtNum){
location='blocked_inv.asp?type=blocked&seqnum='+dtNum+'&InvStatus='+InvStatus+'&dsort='+ dsort+'&dorder='+ dorder+'&Location='+Location+'&UserCoord='+UserCoord+'&RefOrder='+RefOrder+'&VendorID='+VendorID+'&CurSymbol='+CurSymbol+'&RecDate='+RecDate+'&RecDate2='+RecDate2+'&RptCond='+RptCond;
return false
}

function addRow(id){			
var rows = Number(document.form1.Incr.value);			
var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];
var row = document.createElement("TR");
row.setAttribute("bgColor","#ffffff");
            
//create input box
var hf1 = document.createElement("INPUT");
hf1.setAttribute("type","hidden");
hf1.setAttribute("name","aseqnum" + rows);
hf1.setAttribute("value","0");


var ip1 = document.createElement("INPUT");
ip1.setAttribute("TYPE","TEXT");
ip1.setAttribute("name","ActCode" + rows);
ip1.setAttribute("id","AC" + rows);
ip1.setAttribute("size","12");
ip1.setAttribute("className","GridBox");
ip1.onblur=function(){setAmt()};

var bt1=document.createElement("INPUT");
bt1.setAttribute("type","button");
bt1.setAttribute("value","...");
bt1.setAttribute("name","Butt1" + rows);
bt1.setAttribute("className","sbttn");
bt1.onclick=function(){openpopup2('AcctList.asp?fld=AC'+rows)};
				
var ip2 = document.createElement("SELECT");
ip2.setAttribute("name","T0" + rows);
ip2.setAttribute("className","drpdwn");
var opt1 = document.createElement("OPTION");
opt1.innerHTML='';
opt1.value='';
ip2.appendChild(opt1);

<%  CompCode.MoveFirst
    incr=2
    do while not compcode.eof %>

var opt<%= incr %> = document.createElement("OPTION");
opt<%= incr %>.innerHTML='<%=(CompCode("COMPCODE"))%>';
opt<%= incr %>.value='<%=(CompCode("COMPCODE"))%>';
ip2.appendChild(opt<%= incr %>);

<% compcode.movenext
    incr=incr+1
   loop
   %>

var ip3 = document.createElement("INPUT");
ip3.setAttribute("TYPE","TEXT");
ip3.setAttribute("name","T1" + rows);
ip3.setAttribute("id","T1" + rows);
ip3.setAttribute("size","10");
ip3.setAttribute("className","GridBox");

var bt3=document.createElement("INPUT");
bt3.setAttribute("type","button");
bt3.setAttribute("value","...");
bt3.setAttribute("name","Butt3" + rows);
bt3.setAttribute("className","sbttn");
bt3.onclick=function(){openpopup2('AFEList.asp?fld=T1'+rows)};

var ip4 = document.createElement("INPUT");
ip4.setAttribute("TYPE","TEXT");
ip4.setAttribute("name","T2" + rows);
ip4.setAttribute("id","T2" + rows);
ip4.setAttribute("size","6");
ip4.setAttribute("className","GridBox");

var bt4=document.createElement("INPUT");
bt4.setAttribute("type","button");
bt4.setAttribute("value","...");
bt4.setAttribute("name","Butt4" + rows);
bt4.setAttribute("className","sbttn");
bt4.onclick=function(){openpopup2('ActivityList.asp?fld=T2'+rows)};

var ip5 = document.createElement("INPUT");
ip5.setAttribute("TYPE","TEXT");
ip5.setAttribute("name","T3" + rows);
ip5.setAttribute("id","T3" + rows);
ip5.setAttribute("size","12");
ip5.setAttribute("className","GridBox");

var bt5=document.createElement("INPUT");
bt5.setAttribute("type","button");
bt5.setAttribute("value","...");
bt5.setAttribute("name","Butt5" + rows);
bt5.setAttribute("className","sbttn");
bt5.onclick=function(){openpopup2('T3List.asp?fld=T3'+rows)};

var ip6 = document.createElement("INPUT");
ip6.setAttribute("TYPE","TEXT");
ip6.setAttribute("name","Amt" + rows);
ip6.setAttribute("size","20");
ip6.setAttribute("value","0.00");
ip6.setAttribute("className","GridNumBox");
ip6.onblur=function(){Valid_Charge('Amt',this,<%= EXIREG("INVAMOUNT") %>)};
			
//create column
var td1 = document.createElement("TD");
td1.setAttribute("align","right");
td1.appendChild(document.createTextNode(rows+". "));

var td2 = document.createElement("TD");
td2.setAttribute("align","center");
td2.appendChild(document.getElementById("form1").appendChild(hf1));
td2.appendChild(document.getElementById("form1").appendChild(ip1));
td2.appendChild(document.getElementById("form1").appendChild(bt1));

var td3 = document.createElement("TD");
td3.setAttribute("align","center");
td3.appendChild(document.getElementById("form1").appendChild(ip2));

var td4 = document.createElement("TD");
td4.setAttribute("align","center");
td4.appendChild(document.getElementById("form1").appendChild(ip3));
td4.appendChild(document.getElementById("form1").appendChild(bt3));

var td5 = document.createElement("TD");
td5.setAttribute("align","center");
td5.appendChild(document.getElementById("form1").appendChild(ip4));
td5.appendChild(document.getElementById("form1").appendChild(bt4));

var td6 = document.createElement("TD");
td6.setAttribute("align","center");
td6.appendChild(document.getElementById("form1").appendChild(ip5));
td6.appendChild(document.getElementById("form1").appendChild(bt5));


var td7 = document.createElement("TD");
td7.setAttribute("align","center");
td7.appendChild(document.getElementById("form1").appendChild(ip6));
            
row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
row.appendChild(td4);
row.appendChild(td5);
row.appendChild(td6);
row.appendChild(td7);

tbody.appendChild(row);
document.form1.Incr.value = rows + 1;
}


</SCRIPT>
<!-- #include file="pagetop.asp" -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td nowrap bgcolor="#FFFFFF" width="3%" background="images/menu_end.gif">&nbsp;</td>
    <td nowrap bgcolor="#FFFFFF" width="28"> 
      <div align="center"><img src="images/menu_awal_off.gif" width="28" height="33"></div>
    </td>
    <td width="10%" background="images/menuoff.gif" nowrap> 
      <div align="center"><b><a href="#" onClick="return redirect()" class="menu">Add Comment  - Invoice List&nbsp;&nbsp;</a></b></div>
    </td>
    <td nowrap width="28"><img src="images/menu_off_on_separator.gif" width="28" height="33"></td>
    <td width="10%" background="images/menuon.gif" nowrap> 
      <div align="center"><b class="menu">Invoice Detail</b></div>
    </td>
    <td width="28" nowrap background="images/menu_end.gif"><img src="images/Menu_onend.gif" width="11" height="33"></td>
    <td width="10%" nowrap bgcolor="#FFFFFF" background="images/menu_end.gif">&nbsp; 
      
    </td>
    <td bgcolor="#FFFFFF" width="11" background="images/menu_end.gif">&nbsp;</td>
    <td bgcolor="#FFFFFF" background="images/menu_end.gif">&nbsp; 
      
    </td>
  </tr>
  <tr bgcolor="#93bee2"> 
    <td height="20" width="3%" bgcolor="#93bee2">&nbsp;</td>
    <td height="20" width="28" bgcolor="#93bee2">&nbsp;</td>
    <td width="10%" height="20" bgcolor="#93bee2">&nbsp;</td>
    <td height="20" width="28">&nbsp;</td>
    <td width="10%" height="20">&nbsp;</td>
    <td width="28" height="20">&nbsp;</td>
    <td width="10%" height="20">&nbsp;</td>
    <td height="20">&nbsp;</td>
    <td height="20">&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#93bee2">
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%">&nbsp;</td>
    <td width="50%">&nbsp; </td>
    <td>&nbsp;</td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%">&nbsp;</td>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr> 
    <td width="4%" height="22">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF" height="22"><img src="images/curv_data.gif" width="21" height="21"></td>
    <td bgcolor="#FFFFFF" height="22" colspan="2">&nbsp;</td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF" colspan="2"> 
      <form name="form1" method="post" action="Inv_ProcessComment.asp">
        <table width="100%" border="0" cellspacing="2" cellpadding="3">
          <tbody> 
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Register 
                No.:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <%=(EXIREG("REGNUM"))%>
              <input type="hidden" name="seqnum2" value="<%=(EXIREG("SEQNUM"))%>">
            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Invoice No.:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <%=(EXIREG("INVNUM"))%>
              &nbsp;&nbsp;<a href="<%= response.write(EXIREG("REFERENCEDOC")) %>" target="_blank">VIEW INVOICE</a>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="23"> 
              <div align="right"><b>Reference Order:&nbsp;</b></div>
            </td>
            <td width="2%" height="23">&nbsp;</td>
            <td width="30%" height="23"> 
              <% if (EXIREG("REFORDER")="Y") then response.write "Yes" end if%>
              <% if (EXIREG("REFORDER")="N") then response.write "No" end if %>
              <% if (EXIREG("REFORDER")="O") then response.write "Other" end if %>
              <script language="JavaScript">
				function setPO(which){
				if (which.value=="Y"){
				document.form1.reqPONum.readOnly=false;
				document.form1.reqPONum.style.background='#ffffff';
				document.form1.reqPONum.value='';
				document.form1.btnPO.disabled=false;}
				if (which.value=="O"){
				document.form1.reqPONum.readOnly=false;
				document.form1.reqPONum.style.background='#ffffff';
				document.form1.reqPONum.value=' ';
				document.form1.btnPO.disabled=true;}
				if (which.value=="N") {
				document.form1.reqPONum.style.background='#cccccc';
				document.form1.reqPONum.value=' ';
				document.form1.reqPONum.readOnly=true;
				document.form1.btnPO.disabled=true;
					}
				}
				</script>
            </td>
            <td width="15%" bgcolor="#dedede" height="23"> 
              <div align="right"><b>Current Location:&nbsp;</b></div>
            </td>
            <td width="2%" height="23">&nbsp;</td>
            <td bgcolor="#FFFFFF" height="23"><b><font color="#990000"> 
              <% if (EXIREG("LOCATION")="FINANCE") then %>
              FINANCE 
              <% else %>
              <%=(EXIREG("LOCNAME"))%> 
              <% end if %>
              </font></b></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Vendor ID:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <%=(EXIREG("VENDORID"))%>
			</td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Status:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td bgcolor="#FFFFFF"> 
             <%=(EXIREG("INVSTATUS"))%>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Vendor Name:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> 
              <%=(EXIREG("VENDORNAME"))%>
              &nbsp;&nbsp;&nbsp;<b>Vendor Branch:</b> 
              <%=(EXIREG("VENDORBRANCHID"))%>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Received Date:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <%=(EXIREG("INVRECDATE"))%>
              
              
            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Due Date:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <%=(EXIREG("INVDUEDATE"))%>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Received By:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <%=(EXIREG("EMPCODE"))%>
            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Department:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <%=(EXIREG("DEPARTMENT"))%>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <%=(EXIREG("EMPNAME"))%>
            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>PO/SO/CO No:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <%=(EXIREG("PONUM"))%>
              
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Currency:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <%=(EXIREG("INVCURRENCY"))%>
              <input type="hidden" name="curSymbol2" value="<%=(EXIREG("CURRENCYSYMBOL"))%>">
            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Exchange Rate:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <%=(EXIREG("FRATE"))%>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Invoice Amount:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <%=FormatNumber(EXIREG("INVAMOUNT"), -1, -2, -2, -1)%>
            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>T0 Code:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <%
compcode.movefirst
do While NOT CompCode.EOF
%>
                <% if (CompCode("COMPCODE") =EXIREG("COMPCODE")) then 
						response.write CompCode("COMPCODE") & " - " & (CompCode("COMPCODEDESC"))
					end if
				%>
                <%
  CompCode.MoveNext
loop
%>
              
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF"> 
              <div align="right"><b></b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <% if (EXIREG("VATPAIDTOVENDOR")="Y") then 
			  		response.write "<img src='images/check.jpg'>" 
			  	  else
				  	response.write "<img src='images/uncheck.jpg'>"
				  end if
			  %>
              VAT Paid To Vendor</td>
            <td width="15%"> 
              <div align="right"></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td><b></b></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>WHT Name:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <%=(EXIREG("WHTNAME"))%>
            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b><b>WHT Rate:</b></b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <%=(EXIREG("WHTRATE"))%>
              
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>VAT Rate:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="30%"> 
              <%=(EXIREG("VATRATE"))%>
            </td>
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>WHT Amount:</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td> 
              <%=FormatNumber(EXIREG("WHTAMOUNT"), -1, -2, -2, -1)%>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF" height="23">&nbsp;</td>
            <td width="2%" height="23">&nbsp;</td>
            <td width="30%" height="23"> 
              <% if (EXIREG("DOC1")="Y") then 
			  		response.write "<img src='images/check.jpg'>" 
			  	  else
				  	response.write "<img src='images/uncheck.jpg'>"
				  end if 
			  %>
              Original Invoice with Revenue Stamp</td>
            <td width="15%" bgcolor="#FFFFFF" height="23">&nbsp;</td>
            <td width="2%" height="23">&nbsp;</td>
            <td height="23"> 
              <% if (EXIREG("DOC2")="Y") then 
			  		response.write "<img src='images/check.jpg'>" 
			  	  else
				  	response.write "<img src='images/uncheck.jpg'>"
				  end if
			  %>
              Tax Invoices (6 pages)</td>
          </tr>
          
          <tr valign="middle"> 
            <td width="15%" bgcolor="#dedede" height="25"> 
              <div align="right"><b>Verified By: 1.&nbsp;</b></div>
            </td>
            <td width="2%" height="25">&nbsp;</td>
            <td colspan="4" height="25"> <%=(EXIREG("VERIFIEDBY"))%> &nbsp;&nbsp; <%=(EXIREG("VERNAME"))%> &nbsp;&nbsp;&nbsp; 
              <% if (EXIREG("VERIFIEDSTATUS")="VERIFIED") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Verified 
              <%=(DoDateTime((EXIREG("DATEVERIFIED")), 1, 2057))%> 
              <% end if %>
            </td>
          </tr>
           <% Incr = 1  
				do while not Verification.EOF %>
          <tr id="userVer<%= incr %>" > 
            <td width="15%" valign="middle" bgcolor="#dedede"> 
              <div align="right"><b><%= incr + 1 %>.&nbsp;</b></div>
            </td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="5" valign="middle"> 
              <%=(Verification("VERIFIEDBY"))%> &nbsp;&nbsp; <%=(Verification("VERNAME"))%>
              &nbsp;&nbsp;&nbsp;<% if (Verification("VERIFYSTATUS")="VERIFIED") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Verified 
              &nbsp;&nbsp;<%= DoDateTime((Verification("DATEVERIFIED")), 2, 2070) %> 
              <% end if %>
            </td>
          </tr>
          <% Incr = Incr + 1
                  Verification.MoveNext
                  loop %>
          <tr valign="middle"> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right" id="caption1"><b><%= caption1 %>&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> <%=(EXIREG("APPROVEDBY"))%> &nbsp;&nbsp; <%=(EXIREG("APPRNAME"))%> &nbsp;&nbsp;&nbsp; 
              <% if (EXIREG("DATEAPPROVED")<>"") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Approved 
              &nbsp;&nbsp;<%=(DoDateTime((EXIREG("DATEAPPROVED")), 1, 2057))%> 
              <% end if %>
            </td>
          </tr>
          <tr valign="middle" id="Approved2"> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right" id="caption2"><b><%= caption2 %>&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> <%=(EXIREG("APPROVED2BY"))%> &nbsp;&nbsp; <%=(EXIREG("APPRNAME2"))%> &nbsp;&nbsp;&nbsp; 
              <% if (EXIREG("DATEAPPROVED2")<>"") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Approved 
              &nbsp;&nbsp;<%=(DoDateTime((EXIREG("DATEAPPROVED2")), 1, 2057))%> 
              <% end if %>
            </td>
          </tr>
          <tr valign="middle" id="Authorise"> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Authorised By:</b>&nbsp;</div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> <%=(EXIREG("AUTHORISEDBY"))%> &nbsp;&nbsp; <%=(EXIREG("AUTHNAME"))%> &nbsp;&nbsp;&nbsp; 
              <% if (EXIREG("DATEAUTHORISED")<>"") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Authorised 
              &nbsp;&nbsp;<%=(DoDateTime((EXIREG("DATEAUTHORISED")), 1, 2057))%> 
              <% end if %>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#dedede" height="30" valign="top"> 
              <div align="right"><b>Comments:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> 
              <textarea class="MemoBox" name="Comments1" cols="80" rows="7" readonly="true"><%=(EXIREG("COMMENTS"))%></textarea>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp; </td>
            <td colspan="4"> <font color="#FF0000">Add your comments here: </font> 
              <br>
              <textarea name="Comments" cols="60" rows="3" class="InputBox"></textarea>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> 
              <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999" id="Acct_tbl">
                <tr bgcolor="#FFC58A"> 
                  <td width="5%" height="21"> 
                    <div align="center"><b>No</b></div>
                  </td>
                  <td width="17%" height="21" bgcolor="#FFC58A"> 
                    <div align="center"><b>Account Code</b></div>
                  </td>
                  <td width="10%" height="21"> 
                    <div align="center"><b>T0</b></div>
                  </td>
                  <td width="15%" height="21" bgcolor="#FFC58A"> 
                    <div align="center"><b>T1</b></div>
                  </td>
                  <td width="12%" height="21"> 
                    <div align="center"><b>T2</b></div>
                  </td>
                  <td width="18%" height="21"> 
                    <div align="center"><b>T3</b></div>
                  </td>
                  <td height="21"> 
                    <div align="center"><b>Amount (<%=(EXIREG("CURRENCYSYMBOL"))%>)</b></div>
                  </td>
                </tr>
                <% dim Incr 
				Incr = 1 %>
                <% 
Do While NOT Acct.EOF
%>
                <tr> 
                  <td width="5%" bgcolor="#FFFFFF" align="right"> <%= Incr %>.</td>
                  <td width="17%" bgcolor="#FFFFFF"> 
                    <div align="center"> 
                      <input type="hidden" name="aseqnum<%= Incr %>" value="<%=(Acct("SEQNUM"))%>">
                      <%=(Acct("ACCTCODE"))%>
                    </div>
                  </td>
                  <td width="10%" bgcolor="#FFFFFF"> 
                    <div align="center"> 
                      
                        <% CompCode.MoveFirst
While (NOT CompCode.EOF)
%>
                        <% if (Acct("T0CODE")=CompCode("COMPCODE")) then response.write (CompCode("COMPCODE")) %>
                        <%
  CompCode.MoveNext()
Wend
If (CompCode.CursorType > 0) Then
  CompCode.MoveFirst
Else
  CompCode.Requery
End If
%>
                    </div>
                  </td>
                  <td width="15%" bgcolor="#FFFFFF"> 
                    <div align="center"> 
                      <%=(Acct("T1CODE"))%>
                    </div>
                  </td>
                  <td width="12%" bgcolor="#FFFFFF"> 
                    <div align="center"> 
                      <%=(Acct("T2CODE"))%>
					</div>
                  </td>
                  <td width="18%" bgcolor="#FFFFFF"> 
                    <div align="center"> 
                      <%=(Acct("T3CODE"))%>
					</div>
                  </td>
                  <td bgcolor="#FFFFFF"> 
                    <div align="center"> 
                      <%=FormatNumber( Acct("AMOUNT"), -1, -2, -2, -1)%>
                    </div>
                  </td>
                </tr>
                <% Incr = Incr +1

  Acct.MoveNext
loop
%>
                
              </table>
              <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
                <tr> 
                  <td bgcolor="#FFFFFF"> 
                    <% 'end if %>
                    <input type="hidden" name="Incr" value="<%= Incr+1 %>">
                  </td>
                </tr>
              </table>
              <br>
            </td>
          </tr>
          <tr valign="middle" id="inv_hist"> 
            <td width="15%">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> 
              <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#999999">
                <tr bgcolor="#D1DDEF"> 
                  <td width="6%"> 
                    <div align="center"><b>No.</b></div>
                  </td>
                  <td width="12%"> 
                    <div align="center"><b>Date</b></div>
                  </td>
                  <td> 
                    <div align="center"><b>Description</b></div>
                  </td>
                  <td width="15%"> 
                    <div align="center"><b>Department</b></div>
                  </td>
                  <td width="15%"> 
                    <div align="center"><b>Update By</b></div>
                  </td>
                </tr>
                <%  
				 Incr = 1
				 do While NOT InvHist.EOF %>
                <tr bgcolor="#FFFFFF"> 
                  <td width="6%"> 
                    <div align="center"><%= Incr %></div>
                  </td>
                  <td width="12%"> 
                    <div align="center"><%= DoDateTime((InvHist("UPDATESTAMP")), 2, 2070) %></div>
                  </td>
                  <td><%=(InvHist("TRDESCR"))%>&nbsp;<%=(InvHist("LOCNAME"))%></td>
                  <td width="15%"><%=(InvHist("DEPARTMENT"))%></td>
                  <td width="15%"><%=(InvHist("UPDATEUSER"))%></td>
                </tr>
                <% Incr = Incr + 1
 					InvHist.MoveNext
					loop %>
              </table>
            </td>
          </tr>
          <tr valign="middle"> 
            <td width="15%">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> <b>Receipt: </b> 
              <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#999999">
                <tr bgcolor="#D1DDEF"> 
                  <td width="5%"> 
                    <div align="center"><b>No.</b></div>
                  </td>
                  <td width="6%"> 
                    <div align="center"><b>Select</b></div>
                  </td>
                  <td> 
                    <div align="center"><b>Remarks</b></div>
                  </td>
                  <td width="12%"> 
                    <div align="center"><b>Receiver No.</b></div>
                  </td>
                  <td width="12%"> 
                    <div align="center"><b>Date Received</b></div>
                  </td>
                  <td width="10%"> 
                    <div align="center"><b>Qty </b></div>
                  </td>
                  <td width="15%"> 
                    <div align="center"><b> Cost</b></div>
                  </td>
                </tr>
                <% 
				   incr=1 %>
                <% 
Do While NOT Receipt.EOF
%>
                <tr bgcolor="#FFFFFF"> 
                  <td width="5%"> 
                    <div align="center"><%= incr %>.</div>
                  </td>
                  <td width="6%"> 
                    <div align="center"> 
                      <% if (Receipt("INVOICENUM")<>"") then 
					  		response.write "<img src='images/check.jpg'>"
						 else
						 	response.write "<img src='images/uncheck.jpg'>"
						 end if
						 
						
					  %>
                    </div>
                  </td>
                  <td> 
                    <input type="hidden" name="rn<%= Incr %>" value="<%=(Receipt("RECEIVERNUM"))%>">
                    <%=(Receipt("UDF"))%> 
                    <input type="hidden" name="isEdit<%= Incr %>" value="N">
                  </td>
                  <td width="12%"> 
                    <div align="center"><%=(Receipt("RECEIVERNUM"))%></div>
                  </td>
                  <td width="12%"> 
                    <div align="center"><%= DoDateTime((Receipt("DATERECEIVED")), 2, 2057) %></div>
                  </td>
                  <td width="10%"><%=(Receipt("QTYRECEIVED"))%></td>
                  <td width="15%"> 
                    <div align="right"> 
                      <% if (Receipt("UNITCOST")<>0) then %>
                      <%= FormatNumber((Receipt("UNITCOST")), -1, -2, -2, -1) %> 
                      <% end if %>
                      <% if (Receipt("LINECOST")<>0) then %>
                      <%= FormatNumber((Receipt("LINECOST")), -1, -2, -2, -1) %> 
                      <% end if %>
                    </div>
                  </td>
                </tr>
                <% incr=incr+1
  
  Receipt.MoveNext
loop
%>
              </table>
            </td>
          </tr>
          <tr valign="middle"> 
            <td width="15%">&nbsp;</td>
            <td width="2%"> 
              <input type="hidden" name="Incr3" value="<%= Incr %>">
            </td>
            <td colspan="4"> 
              <input type="hidden" name="Location" value="<%= request.querystring("Location") %>">
              <input type="hidden" name="InvStatus" value="<%= request.querystring("InvStatus") %>">
              <input type="hidden" name="UserCoord" value="<%= request.querystring("UserCoord") %>">
              <input type="hidden" name="RefOrder2" value="<%= request.querystring("RefOrder") %>">
              <input type="hidden" name="VendorID" value="<%= request.querystring("VendorID") %>">
              <input type="hidden" name="CurSymbol" value="<%= request.querystring("CurSymbol") %>">
              <input type="hidden" name="dsort" value="<%= Request.querystring("dsort") %>">
              <input type="hidden" name="dorder" value="<%= Request.querystring("dorder") %>">
            </td>
          </tr>
          <% if (EXIREG("INVSTATUS") = "APPROVED") then %>
          <% end if %>
          <tr valign="middle"> 
            <td width="15%" bgcolor="#dedede"> 
              <div align="right"><b>Action:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="4"> 
              <input type="submit" name="Submit" value=" Save Changes " class="sbttn">
              
            </td>
          </tr>
          
          </tbody> 
        </table>
      </form>
    </td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF" colspan="2">&nbsp;</td>
  </tr>
</table>
</body>
</html>
<%
set CompCode=nothing

set Verification=nothing

set InvHist=nothing

set Acct=nothing
%>
